package main

import (
	"github.com/nsqio/go-nsq"
	"fmt"
)

func main() {
	fmt.Println( "start ...." , t())
}


type consumerHandler struct {
	title string
}

func (this *consumerHandler)HandleMessage(message *nsq.Message) error  {
	fmt.Println("message["+this.title+"]" , *message)
	return nil
}


func t() error {
	config := nsq.NewConfig()

	consumer , err := nsq.NewConsumer("test" ,"test_a" , config)
	if err != nil {
		
	}
	consumer.AddHandler(&consumerHandler{title:"test_a"})

	addr := "127.0.0.1:4150"
	err = consumer.ConnectToNSQD(addr)
	if err != nil {
		return err
	}

	stats := consumer.Stats()
	fmt.Println("stats" , stats)

	<-consumer.StopChan
	return nil
}
